export const getLastWeek = (num = 7) => {
  const today = new Date();
  today.setDate(today.getDate() - num);
  const dates: string[] = [];
  for (let i = 0; i < 7; i++) {
    const dateString = `${today.getFullYear()}-${addZeroPrefix(
      today.getMonth() + 1
    )}-${addZeroPrefix(today.getDate())}`;
    dates.push(dateString);
    today.setDate(today.getDate() + 1);
  }
  function addZeroPrefix(num) {
    return num >= 10 ? num : `0${num}`;
  }
  return dates;
};
export function generateDates(
  startDateString,
  endDateString,
  format = "YYYY-MM-DD"
) {
  let start = new Date(startDateString);
  let end = new Date(endDateString);
  if (start > end) [start, end] = [end, start];
  let datesArray: any[] = [];
  while (start <= end) {
    datesArray.push($dayjs(new Date(start)).format(format));
    start.setDate(start.getDate() + 1);
  }
  return datesArray;
}
